import BaseUtil from '@/BaseUtil';
import BuffUtil from '@/BuffUtil';
import STimer from '@/STimer';
import SelectCommon from 'code/Core/Common/SelectCommon';
import TalentBase from 'code/Scripts/Abilities/base/TalentBase';
const desc = `提升${ColorSafe}700|r范围内的友军全属性${ColorSafe}15%|r。|n觉醒效果：全属性提升到${ColorSafe}30%|r`;
const art = 'ReplaceableTextures\\CommandButtons\\BTNUnholyAura.blp';
const name = '全能光环';
const config: TalentConfigModel = {
    id: 'talent_t_TalentOmnipotentArur',
    name,
    desc,
    art,
    buffType: {
        id: 'buff_t_TalentOmnipotentArur',
        art,
        name,
        ubertip: desc,
        attribute: {
            full_property_p: 0.15,
        },
        class: '光环',
        dur: 2,
    },
    buffTypePlus: {
        id: 'buff_t_TalentOmnipotentArur_plus',
        art,
        name: '全能光环[觉醒]',
        ubertip: `提升${ColorSafe}700|r范围内的友军全属性${ColorSafe}30%|r`,
        attribute: {
            full_property_p: 0.3,
        },
        class: '光环',
        dur: 2,
    },
};
export default class TalentOmnipotentArur extends TalentBase {
    static instance: TalentOmnipotentArur;
    private _providers: unit[] = [];
    private _stimer: STimer;
    constructor(p?: TalentConfigModel) {
        super(p);
        TalentOmnipotentArur.instance = this;
        this.setTalentConfig(config);
        this.onAddTalent(this.addTalentEffect);
    }
    addTalentEffect<T extends TalentBase = TalentOmnipotentArur>(u: unit, talent: T) {
        if (this._providers.includes(u)) return;
        this._providers.push(u);
        if (this._stimer == null) {
            this._stimer = BaseUtil.onTimer(1, this.timerEffect);
        }
    }
    timerEffect() {
        let _this = TalentOmnipotentArur.instance;
        for (let p of _this._providers) {
            if (!IsUnitAliveBJ(p)) continue;
            let { plus } = _this.talentUnEffect(p);
            let id = plus ? _this.buffTypePlus.id : _this.buffType.id;
            let us = SelectCommon.getAllyUnitInRange(p, 700);
            for (let u of us) {
                BuffUtil.addBuff(u, id, p);
            }
        }
        return true;
    }
}
